package com.itwen.constant.controller;

import com.itwen.constant.aiService.ConsultantService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {

//    @Autowired
//    private OpenAiChatModel model;
//    @RequestMapping("/chat")
//    public String chat(@RequestParam(name = "question", required = false) String question) {
//        if (question == null || question.isBlank()) {
//            return "Question cannot be blank";
//        }
//        String answer = model.chat(question);
//        return answer;
//    }
    @Autowired
    private ConsultantService consultantService;

    @RequestMapping(value = "/chat",produces = "text/html;charset=UTF-8")
    public Flux<String> chat(String memoryId,String message){
        Flux<String> answer = consultantService.chat(memoryId,message);
        return answer;
    }

//    @RequestMapping("/chat")
//    public String chat(String message){
//        String answer = consultantService.chat(message);
//        return answer;
//    }
}
